﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MarioArena.World.Projectiles
{
    public abstract class AbstractProjectile
    {
        public long Id { get; set; }
        public Vector2 SpawnPosition { get; set; }
        public Vector2 Position { get; set; }
        public Vector2 Direction { get; set; }

        public int Width { get; protected set; }
        public int Height { get; protected set; }

        protected Vector2 mDimensions;
        protected Rectangle mDeletingBounds;

        /// <summary>
        /// Updates the projectile.
        /// </summary>
        public abstract void Update(GameTime gameTime);

        /// <summary>
        /// Draws the projectile.
        /// </summary>
        public abstract void Draw(SpriteBatch spriteBatch);

        /// <summary>
        /// Indicates whether this projectile has exceeded the deleting bounds 
        /// and should be deleted.
        /// </summary>
        /// <returns>Whether the projectile should be deleted.</returns>
        public virtual bool HasExceededDeletingBounds()
        {
            if (this.Position.X + this.mDimensions.X < this.mDeletingBounds.Left
                || this.Position.X > this.mDeletingBounds.Right
                || this.Position.Y + this.mDimensions.Y < this.mDeletingBounds.Top
                || this.Position.Y > this.mDeletingBounds.Bottom)
            {
                return true;
            }
            return false;
        }
    }
}
